/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package com.xored.searchwt.highlight;


/**
 * A textual match in a given object. This class may be instantiated and also subclassed (to add
 * additional match state like accuracy, etc). The element a match is reported
 * against is assumed to contain the match, and the UI will group matches
 * against the same element together. A match has an offset and a length which
 * may be specified in characters or in lines.
 */
public class Match {
	
	public static String MARKER = "com.xored.searchwt.results";
	
	private int fOffset;
	private int fLength;

	/**
	 * Constructs a new Match object.
	 * 
	 * @param element
	 *            the element that contains the match
	 * @param unit
	 *            the unit offset and length are based on
	 * @param offset
	 *            the offset the match starts at
	 * @param length
	 *            the length of the match
	 */
	public Match(int offset, int length) {
		fOffset= offset;
		fLength= length;
	}

	/**
	 * Returns the offset of this match.
	 * 
	 * @return the offset
	 */
	public int getOffset() {
		return fOffset;
	}

	/**
	 * Returns the length of this match.
	 * 
	 * @return the length
	 */
	public int getLength() {
		return fLength;
	}
	
	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append("{");
		buf.append(fOffset);
		buf.append(", ");
		buf.append(fLength);
		buf.append("}");
		return buf.toString();
	}
}
